<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>

	<script>

		// 数组去重，并过滤掉undefined, null, false等非数字数据

		var arr = [1, 2, 3, 4, 2, '1', 5, undefined, null, false];

		function uniq(arr) {

			var tmpArr = [],
				len = arr.length;

			if (len <= 1) {
				return arr;
			}

			for (var i=0; i<len; i++) {
				if (!isInArray(tmpArr, arr[i])) {
					tmpArr.push(arr[i]);
				}
			}

			return tmpArr;

		}

		var isInArray = function(arr, item) {

			var len;

			if (!(typeof item == 'number')) {
				return true;
			}

			len = arr.length;

			for (var i=0; i<len; i++) {
				if (arr[i] == item) {
					return true;
				}
			}

			return false;

		};

		var r = uniq(arr);
		console.log(r);
		
	</script>
</body>
</html>